package com.diudiutechnology.www.yadiudiu.util.utils;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;

import com.diudiutechnology.www.yadiudiu.yadiudiu.main.MyActivity.LoginActivity;

/**
 * Created by Administrator on 2017/9/4.
 */

public class UserHelper {
    public static boolean isLoginWithAction(Context context) {
        if (TextUtils.isEmpty(getToken())) {
            //当未登录时跳转到登陆界面
            Intent intent = new Intent(context, LoginActivity.class);
            context.startActivity(intent);
            return false;
        } else {
            return true;
        }
    }


    /**
     * 获取token
     *
     * @return
     */
    public static String getToken() {
        return SharedPreferencesUtil.getString(SharedPreferencesUtil.Keys.TOKEN_KEYS, "");
    }
}
